<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="gadget.css" rel="stylesheet" type="text/css" />
	</head>
	
	<script type="text/javascript" language="javascript">
		function settingsClosed() {
		  //code to update your gadget
		}

		function initGadget()
		{
			checkState();
			System.Gadget.onDock = checkState;
			System.Gadget.onUndock = checkState;
			
			calcTime();
		}
		
		function calcTime()
		{
			var wdName_long = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
			var wdName_short = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
			var mName_long = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
			var mName_short = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
			
			var dteCurrent = new Date();
			var utcTime = dteCurrent.getTime() + (dteCurrent.getTimezoneOffset() * 60000);
			var utcDate = new Date(utcTime);
			
			var milliSecTotal = (utcDate.getHours() * 60 * 60 * 1000) + (utcDate.getMinutes() * 60 * 1000) + (utcDate.getSeconds() * 1000) + (utcDate.getTime() - Date.parse(utcDate));
			var secTotal = milliSecTotal / 1000;
			var netMinTotal = Math.floor(secTotal / 4);
			var netMin = netMinTotal % 60;
			var netDegrees = (netMinTotal - netMin) / 60;
			
			document.getElementById("timeText").innerHTML = PadDigits(netDegrees, 3) + '° '
				+ PadDigits(netMin, 2) + '′';
				// + PadDigits(netSec, 2) + '′′';
			
			document.getElementById("dayText").innerHTML = wdName_long[dteCurrent.getDay()];//.toUpperCase();
			
			document.getElementById("dateText").innerHTML = mName_long[dteCurrent.getMonth()]//.toUpperCase()
				+ ', ' + dteCurrent.getDate();
			
			setTimeout("calcTime()", 666);
		}
		
		function PadDigits(n, totalDigits) 
		{ 
			n = n.toString(); 
			var pd = ''; 
			if (totalDigits > n.length) 
			{ 
				for (i=0; i < (totalDigits-n.length); i++) 
				{ 
					pd += '0'; 
				} 
			} 
			return pd + n.toString(); 
		}

		function checkState()
		{
			if(!System.Gadget.docked)
			{
				undockedState();
			}
			else if (System.Gadget.docked)
			{
				dockedState();
			}
		}

		function undockedState()
		{

		}

		function dockedState()
		{

		}
	</script>

	<body onload="initGadget()">
		<table id="timeArea">
			<tr>
				<td VALIGN="bottom">
					<div id="timeText"></div>
				</td>
			</tr>
		</table>
		<div id="dayText"></div>
		<div id="dateText"></div>
	</body>
</html>